package com.chapter13.MyCollection.MySet.MyTreeSet;

import java.util.Arrays;
import java.util.HashSet;
import java.util.TreeSet;

public class DeepTreeSet {
    public static void main(String[] args) {
        TreeSet<Integer> ts = new TreeSet<Integer>(Arrays.asList(5,3,1,5,6,7,9,1));
        System.out.println(ts);

        Student stu1 = new Student(2,"zhangsan");
        Student stu2 = new Student(1,"lisi");
        Student stu3 = new Student(3,"wangwu");

        //升序
        TreeSet<Student> tsStudent = new TreeSet<Student>();
        tsStudent.add(stu1);
        tsStudent.add(stu2);
        tsStudent.add(stu3);
        System.out.println(tsStudent);


        //降序
        TreeSet<Student> tsStudent2 = new TreeSet<Student>(new Student.StudentComparator());
        tsStudent2.add(stu1);
        tsStudent2.add(stu2);
        tsStudent2.add(stu3);
        System.out.println(tsStudent2);
    }
}
